package one.stand.service.checkparam;

import one.stand.enums.ResultEnum;
import one.stand.model.ResultModel;
import one.stand.request.WxLoginRequest;
import org.springframework.util.StringUtils;

/**
 * @author Administrator
 */
public class HomeServiceCheckParam {
    /**
     * 微信登陆验证
     *
     * @return
     */
    public static boolean wxLogin(WxLoginRequest requerst) {
        if (StringUtils.isEmpty(requerst.getCode())
                || StringUtils.isEmpty(requerst.getRawData())
                ||StringUtils.isEmpty(requerst.getEncrypteData())
                ||StringUtils.isEmpty(requerst.getIv())
                ||StringUtils.isEmpty(requerst.getSignature())) {
            return true;
        }
        return false;
    }
    /**
     * 微信登陆验证
     *
     * @return
     */
    public static ResultModel wxLoginCheck(WxLoginRequest requerst) {
        if (StringUtils.isEmpty(requerst.getCode()) ) {
           return ResultModel.fail(ResultEnum.PARAM_CHECK,"code: 登陆凭证为空");
        }else if ( StringUtils.isEmpty(requerst.getRawData()) ) {
            return ResultModel.fail(ResultEnum.PARAM_CHECK,"rawData: 用户非敏感信息为控");
        }else if (StringUtils.isEmpty(requerst.getEncrypteData()) ) {
            return ResultModel.fail(ResultEnum.PARAM_CHECK,"encrypteData: 用户敏感信息");
        }else if ( StringUtils.isEmpty(requerst.getIv()) ) {
            return ResultModel.fail(ResultEnum.PARAM_CHECK,"iv: 解密算法的向量为空");
        }else if ( StringUtils.isEmpty(requerst.getSignature())) {
            return ResultModel.fail(ResultEnum.PARAM_CHECK,"signature: 签名为空");
        }
        return null;
    }
}
